package com.smh.a02PaiXuDemo2;

import java.util.Random;

public class XuanZePaXu {
    public static void main(String[] args) {
        int[] arr = {12,34,51,21,23,12,32,43,12,3,234,2};
        xuanze(arr);
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i]+" ");
        }

        int[] arr2 = new int[10000];
        Random random = new Random();
        for (int i = 0; i < arr2.length; i++) {
            arr2[i]=random.nextInt();
        }
        Long start = System.currentTimeMillis();
        xuanze(arr2);
        Long end = System.currentTimeMillis();
        System.out.println(end-start);

    }
    public static int[] xuanze(int[] arr){
        for (int i = 0; i < arr.length-1; i++) {
            for (int j = i; j < arr.length-1; j++) {
                if (arr[i]>arr[j+1]){
                    int temp = arr[i];
                    arr[i]=arr[j+1];
                    arr[j+1]=temp;
                }
            }
        }
        return arr;
    }
}
